<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div class="headlabel"><?php echo $this->__("PRODUCT DETAIL") ?></div>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div class="product-details">
    <div class="no-display">
            <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
    </div>
    <div class="borderimg">
        <?php echo $this->getChildHtml('media') ?>
    </div>
    <div class="product-details-info">
        <?php $categoryIds  =$_product->getCategoryIds();  ?>
        <div class="block-info">
            <?php $filePath="" ?>
            <p class="name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></p>
            <p><?php echo $this->__("NBS Item #") ?>:  <?php echo $_product->getSku() ?></p>
            <p class="bold"><?php echo $this->__("Make") ?>: <?php echo  $_product->getAttributeText('manufacturer') ?></p>
            <?php $sku = $_product->getSku(); ?>
            
            <?php if(!empty($categoryIds)): ?>
                <?php $pdfName = Mage::getModel("catalog/category")->load($categoryIds[0])->getPdfName();?>
          
                <?php if(!empty($pdfName)): ?> 
                    <?php $filePath = Mage::getBaseDir("media")."/catalog/pdf/$pdfName".".pdf"; ?>
                <?php endif;?>
            <?php endif;?>
            
            
            <?php if(file_exists($filePath)): ?>
                <?php $category_id = $categoryIds[0] ?>
                <a class="view-pdf" target="_blank" href="<?php echo $this->getUrl("home/index/exportPdfCatalog/category_id/$category_id") ?>"><?php echo $this->__("View Catalog") ?></a>
            <?php endif; ?>
            
        </div>
        <div class="block-info">
            <?php /*<p><?php echo $this->__("Manufacturer Item") ?>#:  <?php echo $_product->getModelNumber() ?></p>
            
            <?php if(!empty($categoryIds)): ?>
                <p><?php echo $this->__("Catalog Pg #:") ?> <?php echo $categoryIds[0] ?></p>
            <?php endif;?>
			*/?>
        </div>
        
        <div class="block-info detail">
            <p><?php echo $this->__("Product Detail:") ?></p>
            <p><?php echo $_product->getDescription() ?></p>
        </div>
         
       
        <div class="block-info noborder">
            
            <p class="price bold"><?php echo $this->__("Price")?>: <?php echo $this->getChildHtml('product_type_data') ?></p>
             <?php if (!$this->hasOptions()):?>
                
                    <?php if($_product->isSaleable()): ?>
                        <?php echo $this->getChildHtml('addtocart') ?>
                    <?php endif; ?>

                
                <?php echo $this->getChildHtml('extra_buttons') ?>
            <?php elseif (!$_product->isSaleable()): ?>

                    <?php echo $this->getChildHtml('addto') ?>
            <?php endif; ?>
            
            
        </div>
    
    </div>
 </div>
</form>


<script type="text/javascript">
    jQuery("p.in-stock").hide();
    jQuery("p.out-stock").hide();
</script>
<script type="text/javascript">
    //<![CDATA[
        var productAddToCartForm = new VarienForm('product_addtocart_form');
        productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                }
                var e = null;
                try {
                    this.form.submit();
                } catch (e) {
                }
                this.form.action = oldUrl;
                if (e) {
                    throw e;
                }

                if (button && button != 'undefined') {
                    button.disabled = true;
                }
            }
        }.bind(productAddToCartForm);

        productAddToCartForm.submitLight = function(button, url){
            if(this.validator) {
                var nv = Validation.methods;
                delete Validation.methods['required-entry'];
                delete Validation.methods['validate-one-required'];
                delete Validation.methods['validate-one-required-by-name'];
                // Remove custom datetime validators
                for (var methodName in Validation.methods) {
                    if (methodName.match(/^validate-datetime-.*/i)) {
                        delete Validation.methods[methodName];
                    }
                }

                if (this.validator.validate()) {
                    if (url) {
                        this.form.action = url;
                    }
                    this.form.submit();
                }
                Object.extend(Validation.methods, nv);
            }
        }.bind(productAddToCartForm);
    //]]>
    </script>